package com.jxdinfo.hussar.example.tsgl.book.controller;

import com.jxdinfo.hussar.support.mp.base.controller.HussarBaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jxdinfo.hussar.support.audit.core.annotations.AuditLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventGrade;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Arrays;
import com.jxdinfo.hussar.example.tsgl.book.vo.BookPageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import com.jxdinfo.hussar.example.tsgl.book.model.Book;
import com.jxdinfo.hussar.example.tsgl.book.dto.BookBookdataset1;
import com.jxdinfo.hussar.example.tsgl.book.service.BookService;
import com.jxdinfo.hussar.platform.core.base.apiresult.ApiResponse;

/**
 * 图书表控制器
 */
@RestController(value = "tsgl.book.BookController")
@AuditLog(moduleName = "图书表")
@RequestMapping(value = "/tsgl/book")
public class BookController extends HussarBaseController<Book, BookService> {

    private static final Logger logger = LoggerFactory.getLogger(BookController.class);

    @Autowired
    private BookService bookService;

    /**
     * 图书表表单查询
     */
    @AuditLog(moduleName = "图书表", eventDesc = "表单查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @GetMapping("formQuery")
    public ApiResponse<Book> formQuery(@RequestParam(value = "id") String id) {
        return bookService.formQuery(id);
    }

    /**
     * 图书表新增或修改
     */
    @AuditLog(moduleName = "图书表", eventDesc = "新增或修改", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.INSERT)
    @PostMapping("insertOrUpdate")
    public ApiResponse<String> insertOrUpdate(@RequestBody Book book) {
        return bookService.insertOrUpdate(book);
    }

    /**
     * 图书表表格查询（带分页）
     *
     * @param page 分页对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "图书表", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("hussarQueryPage")
    public ApiResponse<BookPageVO> hussarQueryPage(@RequestBody Page<Book> page) {
        return bookService.hussarQueryPage(page);
    }

    /**
     * 图书表表格查询（带分页）
     *
     * @param page 分页对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "图书表", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("hussarQueryPage_order_custom")
    public ApiResponse<BookPageVO> hussarQueryPage_order_custom(@RequestBody Page<Book> page) {
        return bookService.hussarQueryPage_order_custom(page);
    }

    /**
     * 图书表表格批量物理删除
     *
     * @param ids id数组
     * @return 删除成功标识
     */
    @AuditLog(moduleName = "图书表", eventDesc = "批量物理删除", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.DELETE)
    @PostMapping("del")
    public ApiResponse<Boolean> del(@RequestParam(value = "ids") String[] ids) {
        return bookService.del(Arrays.asList(ids));
    }

    /**
     * 图书表表格查询（带分页）
     *
     * @param bookdataset1 查询对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "图书表", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("hussarQuerybookCondition_1Page")
    public ApiResponse<BookPageVO> hussarQuerybookCondition_1Page(@RequestBody BookBookdataset1 bookdataset1) {
        return bookService.hussarQuerybookCondition_1Page(bookdataset1);
    }

    /**
     * 图书表表格查询（带分页）
     *
     * @param bookdataset1 查询对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "图书表", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("hussarQuerybookCondition_1Page_order_custom")
    public ApiResponse<BookPageVO> hussarQuerybookCondition_1Page_order_custom(@RequestBody BookBookdataset1 bookdataset1) {
        return bookService.hussarQuerybookCondition_1Page_order_custom(bookdataset1);
    }

    /**
     * 图书表表格查询
     *
     * @param bookdataset1 查询对象
     * @return 查询结果
     */
    @AuditLog(moduleName = "图书表", eventDesc = "表格查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping("hussarQuerybookCondition_1")
    public ApiResponse<BookPageVO> hussarQuerybookCondition_1(@RequestBody BookBookdataset1 bookdataset1) {
        return bookService.hussarQuerybookCondition_1(bookdataset1);
    }
}
